package org.wsalger.zlhispass2str;


import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		Button butchange=(Button)findViewById(R.id.butchange);		
		//EditText edittextin=(EditText)findViewById(R.id.editText1);
		//TextView textview=(TextView)findViewById(R.id.textView3);
		butchange.setOnClickListener(new OnClickListener()
			{
				public void onClick(View v) {
					EditText edittextin=(EditText)findViewById(R.id.editText1);
					TextView textview=(TextView)findViewById(R.id.textView3);
					StringBuilder sb=new StringBuilder();
					sb.append(change_str(edittextin.getText().toString()));
					textview.setText(sb.toString());
				}
			}
		);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	public static char[] change_str(String a) {
		String tmp_str = a;
		char tmp[] = new char[200];

		for (int i = 0; i < a.length(); i++) {
			tmp_str = tmp_str.toUpperCase();
			switch ((i + 1) % 3) {
			case 0:
				switch (tmp_str.charAt(i)) {
				case '0':
					tmp[i] = '6';
					break;
				case '1':
					tmp[i] = 'J';
					break;
				case '2':
					tmp[i] = 'H';
					break;
				case '3':
					tmp[i] = '9';
					break;
				case '4':
					tmp[i] = 'G';
					break;
				case '5':
					tmp[i] = 'E';
					break;
				case '6':
					tmp[i] = 'Q';
					break;
				case '7':
					tmp[i] = '1';
					break;
				case '8':
					tmp[i] = 'X';
					break;
				case '9':
					tmp[i] = 'L';
					break;
				case 'A':
					tmp[i] = 'S';
					break;
				case 'B':
					tmp[i] = '8';
					break;
				case 'C':
					tmp[i] = '5';
					break;
				case 'D':
					tmp[i] = 'R';
					break;
				case 'E':
					tmp[i] = '7';
					break;
				case 'F':
					tmp[i] = 'M';
					break;
				case 'G':
					tmp[i] = '3';
					break;
				case 'H':
					tmp[i] = 'A';
					break;
				case 'I':
					tmp[i] = 'N';
					break;
				case 'J':
					tmp[i] = 'F';
					break;
				case 'K':
					tmp[i] = 'O';
					break;
				case 'L':
					tmp[i] = '4';
					break;
				case 'M':
					tmp[i] = 'K';
					break;
				case 'N':
					tmp[i] = 'Y';
					break;
				case 'O':
					tmp[i] = 'D';
					break;
				case 'P':
					tmp[i] = '2';
					break;
				case 'Q':
					tmp[i] = 'T';
					break;
				case 'R':
					tmp[i] = 'C';
					break;
				case 'S':
					tmp[i] = 'U';
					break;
				case 'T':
					tmp[i] = 'P';
					break;
				case 'U':
					tmp[i] = 'B';
					break;
				case 'V':
					tmp[i] = 'Z';
					break;
				case 'W':
					tmp[i] = '0';
					break;
				case 'X':
					tmp[i] = 'V';
					break;
				case 'Y':
					tmp[i] = 'I';
					break;
				case 'Z':
					tmp[i] = 'W';
					break;
				default:
					break;
				}
				break;
			case 1:
				switch (tmp_str.charAt(i)) {
				case '0':
					tmp[i] = 'W';
					break;
				case '1':
					tmp[i] = 'I';
					break;
				case '2':
					tmp[i] = 'N';
					break;
				case '3':
					tmp[i] = 'T';
					break;
				case '4':
					tmp[i] = 'E';
					break;
				case '5':
					tmp[i] = 'R';
					break;
				case '6':
					tmp[i] = 'P';
					break;
				case '7':
					tmp[i] = 'L';
					break;
				case '8':
					tmp[i] = 'U';
					break;
				case '9':
					tmp[i] = 'M';
					break;
				case 'A':
					tmp[i] = 'H';
					break;
				case 'B':
					tmp[i] = 'T';
					break;
				case 'C':
					tmp[i] = 'I';
					break;
				case 'D':
					tmp[i] = 'O';
					break;
				case 'E':
					tmp[i] = 'K';
					break;
				case 'F':
					tmp[i] = 'V';
					break;
				case 'G':
					tmp[i] = 'A';
					break;
				case 'H':
					tmp[i] = 'N';
					break;
				case 'I':
					tmp[i] = 'F';
					break;
				case 'J':
					tmp[i] = 'J';
					break;
				case 'K':
					tmp[i] = 'B';
					break;
				case 'L':
					tmp[i] = 'U';
					break;
				case 'M':
					tmp[i] = 'Y';
					break;
				case 'N':
					tmp[i] = 'G';
					break;
				case 'O':
					tmp[i] = 'P';
					break;
				case 'P':
					tmp[i] = 'W';
					break;
				case 'Q':
					tmp[i] = 'R';
					break;
				case 'R':
					tmp[i] = 'M';
					break;
				case 'S':
					tmp[i] = 'E';
					break;
				case 'T':
					tmp[i] = 'S';
					break;
				case 'U':
					tmp[i] = 'T';
					break;
				case 'V':
					tmp[i] = 'Q';
					break;
				case 'W':
					tmp[i] = 'L';
					break;
				case 'X':
					tmp[i] = 'Z';
					break;
				case 'Y':
					tmp[i] = 'C';
					break;
				case 'Z':
					tmp[i] = 'X';
					break;
				default:
					break;
				}
				break;
			case 2:
				switch (tmp_str.charAt(i)) {
				case '0':
					tmp[i] = '7';
					break;
				case '1':
					tmp[i] = 'M';
					break;
				case '2':
					tmp[i] = '3';
					break;
				case '3':
					tmp[i] = 'A';
					break;
				case '4':
					tmp[i] = 'N';
					break;
				case '5':
					tmp[i] = 'F';
					break;
				case '6':
					tmp[i] = 'O';
					break;
				case '7':
					tmp[i] = '4';
					break;
				case '8':
					tmp[i] = 'K';
					break;
				case '9':
					tmp[i] = 'Y';
					break;
				case 'A':
					tmp[i] = '6';
					break;
				case 'B':
					tmp[i] = 'J';
					break;
				case 'C':
					tmp[i] = 'H';
					break;
				case 'D':
					tmp[i] = '9';
					break;
				case 'E':
					tmp[i] = 'G';
					break;
				case 'F':
					tmp[i] = 'E';
					break;
				case 'G':
					tmp[i] = 'Q';
					break;
				case 'H':
					tmp[i] = '1';
					break;
				case 'I':
					tmp[i] = 'T';
					break;
				case 'J':
					tmp[i] = 'C';
					break;
				case 'K':
					tmp[i] = 'U';
					break;
				case 'L':
					tmp[i] = 'P';
					break;
				case 'M':
					tmp[i] = 'B';
					break;
				case 'N':
					tmp[i] = 'Z';
					break;
				case 'O':
					tmp[i] = '0';
					break;
				case 'P':
					tmp[i] = 'V';
					break;
				case 'Q':
					tmp[i] = 'I';
					break;
				case 'R':
					tmp[i] = 'W';
					break;
				case 'S':
					tmp[i] = 'X';
					break;
				case 'T':
					tmp[i] = 'L';
					break;
				case 'U':
					tmp[i] = '5';
					break;
				case 'V':
					tmp[i] = 'R';
					break;
				case 'W':
					tmp[i] = 'D';
					break;
				case 'X':
					tmp[i] = '2';
					break;
				case 'Y':
					tmp[i] = 'S';
					break;
				case 'Z':
					tmp[i] = '8';
					break;
				default:
					break;
				}
				break;

			default:
				break;
			}
		}
		return tmp;
	}
}